<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>咸鱼云 - 日志</title>
    <link rel="stylesheet/less" href="/src/css/xiaotao-ui.less">
    <link rel="stylesheet" href="/src/css/base.css">
    <script src="/src/dep/js/less.min.js"></script>
    <script src="/src/dep/js/vue.js"></script>
    <script src="/src/js/base.js"></script>
    <script src="/src/js/xiaotao-ui.js"></script>
    <style>
        html,body{
            background: none;
            height: auto;
        }
        table{
            border-collapse: collapse;
            background-color: #eee;
        }
        tr{
            line-height: 32px;
        }
        tr td{
            padding: 0 5px;
        }
    </style>
</head>
<body>
    <div id="app">
        <xt-pagination :maxpage="logs.last_page" @page-change='loadData'></xt-pagination>
        <table border="1">
            <thead>
                <tr>
                    <td>等级</td>
                    <td>信息</td>
                    <td>产生者</td>
                    <td>时间</td>
                </tr>
            </thead>
            <tbody>
                <tr class="item" v-for="log in logs.data">
                    <td>{{log.level | showLevel}}</td>
                    <td>{{log.info}}</td>
                    <td>{{log.operator}}</td>
                    <td>{{formatDate(new Date(log.created_at*1000))}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <script>
        app = new Vue({
            el:"#app",
            data:{
                logs:[]
            },methods: {
                loadData(page) {
                    majax('get','/api/admin/System/getLog',{
                        data:{
                            'page':page
                        },
                        success:e=>{
                            if(e.data.status != 1){
                                this.alert("错误代码", "代码：" + e.data.status + "<br>状态：" + e.status)
                            }else{
                                this.logs = e.data

                            }
                        }
                    })
                },
            },
            created(){
                this.loadData(1)
            },filters:{
                showLevel(num){
                    switch (num) {
                        case 0:return '操作'
                        case 1:return '信息'
                        case 2:return '警告'
                        case 3:return '危险'
                        case 4:return '数据记录'
                        default:
                            return num
                            break;
                    }
                }
            }
        })
    </script>
</body>
</html>
